package org.example.controller;

import org.example.result.ServerResponse;
import org.example.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 订单controller
 *
 * @author: User
 * @description:
 * @create: 2024-07-23 16:41
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderService iOrderService;

  /**
   * 用户订单列表
   * @author: user
   * @date: 2024-07-25 13:48:38
   * @param
   * @return org.example.result.ServerResponse
   */
    @PostMapping("/list")
    public ServerResponse list() {
        return ServerResponse.operateSuccess(
                iOrderService.getUserOrderList());
    }

    /**
     * 用户订单分页列表
     * @author: user
     * @date: 2024-07-25 14:08:49
     * @param
     * @return org.example.result.ServerResponse
     */
    @PostMapping("/page")
    public ServerResponse page() {
        return ServerResponse.operateSuccess(
                iOrderService.getUserOrderListPage());
    }

    /**
     * 单个用户订单列表
     * @author: user
     * @date: 2024-07-25 13:48:38
     * @param userId
     * @return org.example.result.ServerResponse
     */
    @PostMapping("/userOrder")
    public ServerResponse userOrder(Integer userId) {
        return ServerResponse.operateSuccess(
                iOrderService.getOrderOfUserId(userId));
    }

}
